// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
//
//------------------------------------------------------------------------------
// This code was generated by google-apis-code-generator 1.5.1
//
//  Changes to this file may cause incorrect behavior and will be lost if
//  the code is regenerated.
//------------------------------------------------------------------------------
#include "google/wax_api/wax_service.h"

#include <string>
#include "googleapis/client/service/client_service.h"
#include "googleapis/client/util/status.h"

#include "google/wax_api/subscription.h"
#include "google/wax_api/wax_create_session_request.h"
#include "google/wax_api/wax_data_item.h"
#include "google/wax_api/wax_list_response.h"
#include "google/wax_api/wax_new_session_request.h"
#include "google/wax_api/wax_new_session_response.h"
#include "google/wax_api/wax_remove_session_request.h"
#include "google/wax_api/wax_remove_session_response.h"


#include "googleapis/client/data/data_reader.h"
#include "googleapis/client/transport/http_request.h"
#include "googleapis/client/transport/http_transport.h"
#include "googleapis/client/util/uri_utils.h"
#include "googleapis/strings/strcat.h"

namespace google_wax_api {
using namespace googleapis;
const StringPiece WaxService::googleapis_API_NAME("wax");

const StringPiece WaxService::googleapis_API_VERSION("v1");

const StringPiece WaxService::googleapis_API_GENERATOR(
  "google-apis-code-generator 1.5.1 / 0.1.3");


const StringPiece WaxService::SCOPES::XAPI_ZOO("https://www.googleapis.com/auth/xapi.zoo");

const StringPiece WaxService::SCOPES::XAPI_ZOO_READONLY("https://www.googleapis.com/auth/xapi.zoo.readonly");
WaxServiceBaseRequest::WaxServiceBaseRequest(
      const client::ClientService* service,
      client::AuthorizationCredential* credential,
      client::HttpRequest::HttpMethod method,
      const StringPiece& uri_template)
    : client::ClientServiceRequest(
          service, credential, method, uri_template),
      alt_("json"),
      pretty_print_(true),
      _have_alt_(false),
      _have_fields_(false),
      _have_key_(false),
      _have_oauth_token_(false),
      _have_pretty_print_(false),
      _have_quota_user_(false),
      _have_user_ip_(false) {
}

WaxServiceBaseRequest::~WaxServiceBaseRequest() {
}

util::Status WaxServiceBaseRequest::AppendVariable(
    const StringPiece& variable_name,
    const client::UriTemplateConfig& config,
    string* target) {
  return client::StatusInvalidArgument(
      StrCat("Unknown url variable='", variable_name, "'"));
}

util::Status WaxServiceBaseRequest::AppendOptionalQueryParameters(
    string* target) {
  const char* sep = (target->find('?') == string::npos) ? "?" : "&";
  if (_have_alt_) {
    StrAppend(target, sep, "alt=",
              client::CppValueToEscapedUrlValue(
                alt_));
    sep = "&";
  }
  if (_have_fields_) {
    StrAppend(target, sep, "fields=",
              client::CppValueToEscapedUrlValue(
                fields_));
    sep = "&";
  }
  if (_have_key_) {
    StrAppend(target, sep, "key=",
              client::CppValueToEscapedUrlValue(
                key_));
    sep = "&";
  }
  if (_have_oauth_token_) {
    StrAppend(target, sep, "oauth_token=",
              client::CppValueToEscapedUrlValue(
                oauth_token_));
    sep = "&";
  }
  if (_have_pretty_print_) {
    StrAppend(target, sep, "prettyPrint=",
              client::CppValueToEscapedUrlValue(
                pretty_print_));
    sep = "&";
  }
  if (_have_quota_user_) {
    StrAppend(target, sep, "quotaUser=",
              client::CppValueToEscapedUrlValue(
                quota_user_));
    sep = "&";
  }
  if (_have_user_ip_) {
    StrAppend(target, sep, "userIp=",
              client::CppValueToEscapedUrlValue(
                user_ip_));
    sep = "&";
  }
  return client::ClientServiceRequest
         ::AppendOptionalQueryParameters(target);
}


void WaxServiceBaseRequest::AddJsonContentToRequest(
    const client::JsonCppData *content) {
  client::HttpRequest* _http_request_ = mutable_http_request();
  _http_request_->set_content_type(
        client::HttpRequest::ContentType_JSON);
  _http_request_->set_content_reader(content->MakeJsonReader());
}



// Standard constructor.
ItemsResource_DeleteMethod::ItemsResource_DeleteMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::DELETE,
        StrCat(_service_->service_url(), "sessions/{sessionId}/items/{itemId}")),
      session_id_(session_id.as_string()),
      item_id_(item_id.as_string()) {
}

// Standard destructor.
ItemsResource_DeleteMethod::~ItemsResource_DeleteMethod() {
}


util::Status ItemsResource_DeleteMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  if (variable_name == "sessionId") {
    client::UriTemplate::AppendValue(
        session_id_, config, target);
    return client::StatusOk();
  }
  if (variable_name == "itemId") {
    client::UriTemplate::AppendValue(
        item_id_, config, target);
    return client::StatusOk();
  }
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
ItemsResource_GetMethod::ItemsResource_GetMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::GET,
        StrCat(_service_->service_url(), "sessions/{sessionId}/items/{itemId}")),
      session_id_(session_id.as_string()),
      item_id_(item_id.as_string()) {
}

// Standard destructor.
ItemsResource_GetMethod::~ItemsResource_GetMethod() {
}


util::Status ItemsResource_GetMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  if (variable_name == "sessionId") {
    client::UriTemplate::AppendValue(
        session_id_, config, target);
    return client::StatusOk();
  }
  if (variable_name == "itemId") {
    client::UriTemplate::AppendValue(
        item_id_, config, target);
    return client::StatusOk();
  }
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
ItemsResource_InsertMethod::ItemsResource_InsertMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const StringPiece& session_id, const WaxDataItem& __request_content__)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::POST,
        StrCat(_service_->service_url(), "sessions/{sessionId}/items")),
      session_id_(session_id.as_string()) {
  AddJsonContentToRequest(&__request_content__);
}

// Standard destructor.
ItemsResource_InsertMethod::~ItemsResource_InsertMethod() {
}


util::Status ItemsResource_InsertMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  if (variable_name == "sessionId") {
    client::UriTemplate::AppendValue(
        session_id_, config, target);
    return client::StatusOk();
  }
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
ItemsResource_ListMethod::ItemsResource_ListMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const StringPiece& session_id)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::GET,
        StrCat(_service_->service_url(), "sessions/{sessionId}/items")),
      session_id_(session_id.as_string()) {
}

// Standard destructor.
ItemsResource_ListMethod::~ItemsResource_ListMethod() {
}


util::Status ItemsResource_ListMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  if (variable_name == "sessionId") {
    client::UriTemplate::AppendValue(
        session_id_, config, target);
    return client::StatusOk();
  }
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
ItemsResource_PatchMethod::ItemsResource_PatchMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id, const WaxDataItem& __request_content__)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::PATCH,
        StrCat(_service_->service_url(), "sessions/{sessionId}/items/{itemId}")),
      session_id_(session_id.as_string()),
      item_id_(item_id.as_string()) {
  AddJsonContentToRequest(&__request_content__);
}

// Standard destructor.
ItemsResource_PatchMethod::~ItemsResource_PatchMethod() {
}


util::Status ItemsResource_PatchMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  if (variable_name == "sessionId") {
    client::UriTemplate::AppendValue(
        session_id_, config, target);
    return client::StatusOk();
  }
  if (variable_name == "itemId") {
    client::UriTemplate::AppendValue(
        item_id_, config, target);
    return client::StatusOk();
  }
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
ItemsResource_SubscribeMethod::ItemsResource_SubscribeMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const StringPiece& session_id, const Subscription& __request_content__)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::POST,
        StrCat(_service_->service_url(), "sessions/{sessionId}/items/subscribe")),
      session_id_(session_id.as_string()) {
  AddJsonContentToRequest(&__request_content__);
}

// Standard destructor.
ItemsResource_SubscribeMethod::~ItemsResource_SubscribeMethod() {
}


util::Status ItemsResource_SubscribeMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  if (variable_name == "sessionId") {
    client::UriTemplate::AppendValue(
        session_id_, config, target);
    return client::StatusOk();
  }
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
ItemsResource_SubscribeToOneItemMethod::ItemsResource_SubscribeToOneItemMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id, const Subscription& __request_content__)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::POST,
        StrCat(_service_->service_url(), "sessions/{sessionId}/items/{itemId}/subscribe")),
      session_id_(session_id.as_string()),
      item_id_(item_id.as_string()) {
  AddJsonContentToRequest(&__request_content__);
}

// Standard destructor.
ItemsResource_SubscribeToOneItemMethod::~ItemsResource_SubscribeToOneItemMethod() {
}


util::Status ItemsResource_SubscribeToOneItemMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  if (variable_name == "sessionId") {
    client::UriTemplate::AppendValue(
        session_id_, config, target);
    return client::StatusOk();
  }
  if (variable_name == "itemId") {
    client::UriTemplate::AppendValue(
        item_id_, config, target);
    return client::StatusOk();
  }
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
ItemsResource_UpdateMethod::ItemsResource_UpdateMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id, const WaxDataItem& __request_content__)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::PUT,
        StrCat(_service_->service_url(), "sessions/{sessionId}/items/{itemId}")),
      session_id_(session_id.as_string()),
      item_id_(item_id.as_string()) {
  AddJsonContentToRequest(&__request_content__);
}

// Standard destructor.
ItemsResource_UpdateMethod::~ItemsResource_UpdateMethod() {
}


util::Status ItemsResource_UpdateMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  if (variable_name == "sessionId") {
    client::UriTemplate::AppendValue(
        session_id_, config, target);
    return client::StatusOk();
  }
  if (variable_name == "itemId") {
    client::UriTemplate::AppendValue(
        item_id_, config, target);
    return client::StatusOk();
  }
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
SessionsResource_CreateMethod::SessionsResource_CreateMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const WaxCreateSessionRequest& __request_content__)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::POST,
        StrCat(_service_->service_url(), "sessions/create")) {
  AddJsonContentToRequest(&__request_content__);
}

// Standard destructor.
SessionsResource_CreateMethod::~SessionsResource_CreateMethod() {
}


// Standard constructor.
SessionsResource_NewSessionMethod::SessionsResource_NewSessionMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const WaxNewSessionRequest& __request_content__)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::POST,
        StrCat(_service_->service_url(), "newsession")),
      _have_session_name_(false) {
  AddJsonContentToRequest(&__request_content__);
}

// Standard destructor.
SessionsResource_NewSessionMethod::~SessionsResource_NewSessionMethod() {
}

util::Status SessionsResource_NewSessionMethod::AppendOptionalQueryParameters(string* target) {
  const char* sep = (target->find('?') == string::npos) ? "?" : "&";
  if (_have_session_name_) {
    StrAppend(target, sep, "sessionName=",
              client::CppValueToEscapedUrlValue(
                session_name_));
    sep = "&";
  }
  return WaxServiceBaseRequest::AppendOptionalQueryParameters(target);
}
util::Status SessionsResource_NewSessionMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
SessionsResource_RemoveSessionMethod::SessionsResource_RemoveSessionMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const WaxRemoveSessionRequest& __request_content__)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::POST,
        StrCat(_service_->service_url(), "removesession")),
      _have_session_id_(false) {
  AddJsonContentToRequest(&__request_content__);
}

// Standard destructor.
SessionsResource_RemoveSessionMethod::~SessionsResource_RemoveSessionMethod() {
}

util::Status SessionsResource_RemoveSessionMethod::AppendOptionalQueryParameters(string* target) {
  const char* sep = (target->find('?') == string::npos) ? "?" : "&";
  if (_have_session_id_) {
    StrAppend(target, sep, "sessionId=",
              client::CppValueToEscapedUrlValue(
                session_id_));
    sep = "&";
  }
  return WaxServiceBaseRequest::AppendOptionalQueryParameters(target);
}
util::Status SessionsResource_RemoveSessionMethod::AppendVariable(
        const StringPiece& variable_name,
        const client::UriTemplateConfig& config,
        string* target) {
  return WaxServiceBaseRequest::AppendVariable(
      variable_name, config, target);
}


// Standard constructor.
SubscriptionsResource_UnsubscribeMethod::SubscriptionsResource_UnsubscribeMethod(
    const WaxService* _service_, client::AuthorizationCredential* _credential_, const Subscription& __request_content__)
    : WaxServiceBaseRequest(
        _service_, _credential_,
        client::HttpRequest::POST,
        StrCat(_service_->service_url(), "subscriptions/unsubscribe")) {
  AddJsonContentToRequest(&__request_content__);
}

// Standard destructor.
SubscriptionsResource_UnsubscribeMethod::~SubscriptionsResource_UnsubscribeMethod() {
}



WaxService::WaxService(client::HttpTransport* transport)
  : ClientService("https://www.googleapis.com/", "wax/v1/", transport), items_(this), sessions_(this), subscriptions_(this) {
}

WaxService::~WaxService() {
}


WaxService::ItemsResource::ItemsResource(WaxService* service)
  : service_(service) {
}



ItemsResource_DeleteMethod* WaxService::ItemsResource::NewDeleteMethod(client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id) const {
  return new ItemsResource_DeleteMethod(service_, _credential_, session_id, item_id);
}


ItemsResource_GetMethod* WaxService::ItemsResource::NewGetMethod(client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id) const {
  return new ItemsResource_GetMethod(service_, _credential_, session_id, item_id);
}


ItemsResource_InsertMethod* WaxService::ItemsResource::NewInsertMethod(client::AuthorizationCredential* _credential_, const StringPiece& session_id, const WaxDataItem& __request_content__) const {
  return new ItemsResource_InsertMethod(service_, _credential_, session_id, __request_content__);
}


ItemsResource_ListMethod* WaxService::ItemsResource::NewListMethod(client::AuthorizationCredential* _credential_, const StringPiece& session_id) const {
  return new ItemsResource_ListMethod(service_, _credential_, session_id);
}


ItemsResource_PatchMethod* WaxService::ItemsResource::NewPatchMethod(client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id, const WaxDataItem& __request_content__) const {
  return new ItemsResource_PatchMethod(service_, _credential_, session_id, item_id, __request_content__);
}


ItemsResource_SubscribeMethod* WaxService::ItemsResource::NewSubscribeMethod(client::AuthorizationCredential* _credential_, const StringPiece& session_id, const Subscription& __request_content__) const {
  return new ItemsResource_SubscribeMethod(service_, _credential_, session_id, __request_content__);
}


ItemsResource_SubscribeToOneItemMethod* WaxService::ItemsResource::NewSubscribeToOneItemMethod(client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id, const Subscription& __request_content__) const {
  return new ItemsResource_SubscribeToOneItemMethod(service_, _credential_, session_id, item_id, __request_content__);
}


ItemsResource_UpdateMethod* WaxService::ItemsResource::NewUpdateMethod(client::AuthorizationCredential* _credential_, const StringPiece& session_id, const StringPiece& item_id, const WaxDataItem& __request_content__) const {
  return new ItemsResource_UpdateMethod(service_, _credential_, session_id, item_id, __request_content__);
}

WaxService::SessionsResource::SessionsResource(WaxService* service)
  : service_(service) {
}



SessionsResource_CreateMethod* WaxService::SessionsResource::NewCreateMethod(client::AuthorizationCredential* _credential_, const WaxCreateSessionRequest& __request_content__) const {
  return new SessionsResource_CreateMethod(service_, _credential_, __request_content__);
}


SessionsResource_NewSessionMethod* WaxService::SessionsResource::NewNewSessionMethod(client::AuthorizationCredential* _credential_, const WaxNewSessionRequest& __request_content__) const {
  return new SessionsResource_NewSessionMethod(service_, _credential_, __request_content__);
}


SessionsResource_RemoveSessionMethod* WaxService::SessionsResource::NewRemoveSessionMethod(client::AuthorizationCredential* _credential_, const WaxRemoveSessionRequest& __request_content__) const {
  return new SessionsResource_RemoveSessionMethod(service_, _credential_, __request_content__);
}

WaxService::SubscriptionsResource::SubscriptionsResource(WaxService* service)
  : service_(service) {
}



SubscriptionsResource_UnsubscribeMethod* WaxService::SubscriptionsResource::NewUnsubscribeMethod(client::AuthorizationCredential* _credential_, const Subscription& __request_content__) const {
  return new SubscriptionsResource_UnsubscribeMethod(service_, _credential_, __request_content__);
}
}  // namespace google_wax_api
